<?php


namespace App\controllers\admin;


use App\controllers\Base;
use Consts\RedisKey;
use Helper\Output;
use Helper\Mysql;
use Helper\Redis;
use Helper\Reg;


class Customer extends Base
{


    /**
     * 设置客户备注
     * @param $request
     * @param $response
     */
    public function setCustomerInfo($request, $response){

        $id = $request->post['id'];
        unset($request->post['id']);

        $res  = Mysql::getInstance()
                ->where('id',$id)
                ->update('customer',$request->post);

        if($res){
            $sessInfo = Redis::getInstance()->hget(RedisKey::online_customer_list($this->getUserId()),'uid:'.$id);
            if($sessInfo){
                $sessInfo = json_decode($sessInfo ,true);
                $sessInfo['user'] = Mysql::getInstance()->where('id',$id)->getOne('customer');
                Redis::getInstance()->hset(RedisKey::online_customer_list($this->getUserId()),'uid:'.$id ,json_encode($sessInfo));
            }
            return Output::json(200);
        }else{
            return Output::json(400);
        }

    }










}